package com.ruoyi.web.controller.production.greenhousefilm;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.domain.greenhousefilm.GreenhousefilmPurchaseApply;
import com.ruoyi.production.service.greenhousefilm.IGreenhousefilmPurchaseApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 棚膜购买申请Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/system/greenhousefilmpply")
@Api("棚膜购买申请")
public class GreenhousefilmPurchaseApplyController extends BaseController
{
    @Autowired
    private IGreenhousefilmPurchaseApplyService greenhousefilmPurchaseApplyService;

    /**
     * 查询棚膜购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:greenhousefilmpply:list')")
    @GetMapping("/list")
    @ApiOperation("查询棚膜购买申请")
    public TableDataInfo list(GreenhousefilmPurchaseApply greenhousefilmPurchaseApply)
    {
        startPage();
        List<GreenhousefilmPurchaseApply> list = greenhousefilmPurchaseApplyService.selectGreenhousefilmPurchaseApplyList(greenhousefilmPurchaseApply);
        return getDataTable(list);
    }

    /**
     * 导出棚膜购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:greenhousefilmpply:export')")
    @Log(title = "棚膜购买申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GreenhousefilmPurchaseApply greenhousefilmPurchaseApply)
    {
        List<GreenhousefilmPurchaseApply> list = greenhousefilmPurchaseApplyService.selectGreenhousefilmPurchaseApplyList(greenhousefilmPurchaseApply);
        ExcelUtil<GreenhousefilmPurchaseApply> util = new ExcelUtil<GreenhousefilmPurchaseApply>(GreenhousefilmPurchaseApply.class);
        return util.exportExcel(list, "棚膜购买申请数据");
    }

    /**
     * 获取棚膜购买申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:greenhousefilmpply:query')")
    @GetMapping(value = "/{greenhousefilmPurchaseApplyId}")
    public AjaxResult getInfo(@PathVariable("greenhousefilmPurchaseApplyId") Long greenhousefilmPurchaseApplyId)
    {
        return AjaxResult.success(greenhousefilmPurchaseApplyService.selectGreenhousefilmPurchaseApplyById(greenhousefilmPurchaseApplyId));
    }

    /**
     * 新增棚膜购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:greenhousefilmpply:add')")
    @Log(title = "棚膜购买申请", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增棚膜购买申请")
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody GreenhousefilmPurchaseApply greenhousefilmPurchaseApply)
    {
        return toAjax(greenhousefilmPurchaseApplyService.insertGreenhousefilmPurchaseApply(greenhousefilmPurchaseApply));
    }

    /**
     * 修改棚膜购买申请
     */
    @PreAuthorize("@ss.hasAnyPermi('system:greenhousefilmpply:edit,system:greenhousefilmpply:permit')")
    @Log(title = "棚膜购买申请", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    @ApiOperation("修改棚膜购买申请")
    public AjaxResult edit(@RequestBody GreenhousefilmPurchaseApply greenhousefilmPurchaseApply)
    {
        return toAjax(greenhousefilmPurchaseApplyService.updateGreenhousefilmPurchaseApply(greenhousefilmPurchaseApply));
    }

    /**
     * 删除棚膜购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:greenhousefilmpply:remove')")
    @Log(title = "棚膜购买申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{greenhousefilmPurchaseApplyIds}")
    @ApiOperation("删除棚膜购买申请")
    public AjaxResult remove(@PathVariable Long[] greenhousefilmPurchaseApplyIds)
    {
        return toAjax(greenhousefilmPurchaseApplyService.deleteGreenhousefilmPurchaseApplyByIds(greenhousefilmPurchaseApplyIds));
    }
}
